package com.lancoo.znbkxx.teacher.aibkTestCoach.paperToEvaluation.aibkEvalutionZHT

import aibkTestReview.quesWrongTutor.aibkTutorPPT.EvaluationAdapterChildTable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseRecyclerAdapter
import com.lancoo.znbkxx.teacher.aibkTestCoach.kBase.KBaseRecyclerViewHolder
import com.lancoo.znbkxx.teacher.aibkTestCoach.networkRequest.entity.PaperEvaluationInfor
import com.lancoo.znbkxx.teacher.aibkTestCoach.paperToEvaluation.PaperEvaluationInforIndexHelp.getChildListBean
import kotlinx.android.synthetic.main.aibk_adapter_item_parent_table.view.*

class EvaluationAdapterParentTable(
        val activity: AppCompatActivity,
        val paperEvaluationInfor: PaperEvaluationInfor,
        val index_A:Int,
        val index_B:Int,
        val index_C:Int
) : KBaseRecyclerAdapter(){

    override fun getHolderView(parent: ViewGroup?, position: Int): View? {
        return LayoutInflater.from(activity)
                .inflate(R.layout.aibk_adapter_item_parent_table, parent, false)
    }

    override fun onBindViewHolder(holder: KBaseRecyclerViewHolder, position: Int) {

        val itemAnswer = getChildListBean(paperEvaluationInfor, index_A, index_B, index_C).ItemList[position].ItemAnswer
        val itemSortIndex = getChildListBean(paperEvaluationInfor, index_A, index_B, index_C).ItemList[position].ItemSortIndex
        holder.convertView.TvItemIndex.text = "$itemSortIndex. "

        var manager = LinearLayoutManager(activity)
        manager.orientation = LinearLayoutManager.HORIZONTAL
        holder.convertView.RvTableViewParent.layoutManager = manager
        val mAdapter = EvaluationAdapterChildTable(activity, paperEvaluationInfor,index_A,index_B,index_C,itemAnswer)
        holder.convertView.RvTableViewParent.adapter = mAdapter
    }

    override fun getItemCount(): Int {
        return getChildListBean(paperEvaluationInfor, index_A, index_B, index_C).ItemList.size
    }

    override fun getItemViewType(position: Int): Int {
        return position
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

}